<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">网班管理</div>
		</div>
		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">


		<div class="row mbl" >
			<div class="col-lg-10">
				<table style="width: 100%;">
					<tr height="50">
						<td align="right" style="width: 100px;">网班名称:&nbsp;&nbsp;</td>
						<td><input type="text"  class="form-control"id="name" name="name" /></td>
						<td align="right" style="width: 100px;">标签:&nbsp;&nbsp;</td>
						<td><input type="text"  class="form-control"id="tag" name="tag" /></td>
					</tr>
					<tr height="50">
						<td align="right" style="width: 100px;">审核类型:&nbsp;&nbsp;</td>
						<td>
							<select class="form-control" id="auditType">
									<option value="">全部</option>
									<option value="0">注册</option>
									<option value="1">注销</option>
									<option value="2">上架</option>
									<option value="3">下架</option>
							</select>	
						</td><td align="right" style="width: 100px;">状态:&nbsp;&nbsp;</td>
						<td>
							<select class="form-control" id="status">
									<option value="">全部</option>
									<option value="0">待审核</option>
									<option value="1">不通过</option>
									<option value="2">通过</option>
							</select>	
						</td>
						<td align="right" style="width: 100px;"><button type="button" data-toggle="dropdown" class="btn btn-blue dropdown-toggle" onclick="get()">查询</button></td>
					</tr>
				</table>
				<button class="btn btn-sm btn-blue" onclick="shenhe('0')">注册审核 </button>&nbsp;&nbsp;
				<button class="btn btn-sm btn-blue" onclick="shenhe('1')">注销审核 </button>&nbsp;&nbsp;
				<button class="btn btn-sm btn-blue" onclick="shenhe('2')">上架审核 </button>&nbsp;&nbsp;
				<button class="btn btn-sm btn-blue" onclick="shenhe('3')">下架审核 </button>&nbsp;&nbsp;
			</div>
		</div>

		<table
			class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
			<thead>
				<tr>
					<th>选择</th>
					<th>序号</th>
					<th>网班名称</th>
					<th>网班标签</th>
					<th>授课教师</th>
					<th>状态</th>
					<th>可操作</th>
				</tr>
			</thead>
			<tbody id="findUser">
				<!-- <tr>
					<td><input name="checkall" type="checkbox"/></td>
					<td>1</td>
					<td>高中语文提分攻略</td>
					<td>开始时间：2019-11-01 9:00<br/>
						结束时间：2019-11-02 9:00</td>
					<td>唐诗三百首；阅读理解；</td>
					<td>刘美丽；李四</td>
					<td>￥1200</td>
					<td>已上架</td>
					<td>
						<button type="button" class="btn btn-default btn-xs" onclick="wangbanDetail()">网班详情</button>&nbsp;
						<button type="button" class="btn btn-default btn-xs" onclick="wangbanPingjia()">评价详情</button>&nbsp;
					</td>
				</tr> -->
				
			</tbody>
		</table>
		<div id="page2" style="text-align: center; margin-top: 20px;"></div>
		<div id="dataNull" class="panel-body"
				style="height: 90px; line-height: 50px;" align="center">
		</div>
	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script>
	var curr;
	var id;
	$(function() {
		demo1(1);
	});
	function get() {
		demo1(curr);
	}
	
	function demo1(cur) {
		$.getJSON("./classesOnlineList.do",
			{
				page : cur || 1,
				name:$("#name").val(),
        		tag:$("#tag").val(),
        		auditType:$("#auditType").val(),
				status:$("#status").val(),
			},
			function(res) {
				//此处仅仅是为了演示变化的内容
				var str = "";
				$("#findUser").html("");
				if(res.listsize>0){
					$("#dataNull").html("");
				}else{
					$("#dataNull").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
				}
				for ( var i = 0; i < res.listsize; i++) {
					str += "<tr><td>"
							+ '<input name="checkall" type="radio" value="'+res.result[i].id+'" auditType="'+res.result[i].auditType+'" status="'+res.result[i].status+'"/>'
							+ '</td><td>'
							+ (i + 1)
							+ "</td><td> <label id=>"
							+ res.result[i].name
							+ "</label></td><td><label >"
							+ res.result[i].tag
							+ "</label></td><td><label >"
							+ res.result[i].userIds
							+ "</label></td><td>";
							if(res.result[i].auditType=='0'){
								str+="注册：";
							}else if(res.result[i].auditType=='1'){
								str+="注销：";
							}else if(res.result[i].auditType=='2'){
								str+="上架：";
							}else if(res.result[i].auditType=='3'){
								str+="下架：";
							}
							if(res.result[i].status=='0'){
								str+='待审核';
							}else if(res.result[i].status=='1'){
								str+='不通过';
							}else if(res.result[i].status=='2'){
								str+='通过';
							}
							str+= "</label></td><td>"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"onclick=\"wangbanDetail('"
							+ res.result[i].id
							+ "')\">"
							+ "网班详情"
							+ "</button>&nbsp;"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"wangbanPingjia('"
							+ res.result[i].id
							+ "')\">"
							+ "评价详情"
							+ "</button>&nbsp;"
							+ "<button type=\"button\" class=\"btn btn-blue btn-xs\"onclick=\"auditShow('"
							+ "2','"
							+ res.result[i].id
							+ "')\">"
							+ "查看审核进度"
							+ "</button>&nbsp;" 
							+ "</td></tr>";
				}
				$("#findUser").append(str);

				laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : res.pageSize, //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: cur || 1,
					last: res.pageSize,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo1(obj.curr);
			                 curr=obj.curr;
						}
					}
				});
			});
	};





function wangbanDetail(id) {
	layer.open({
		type : 2,
		area : [ '750px', '580px' ],
		fix : false, //不固定
		scrollbar : false,
		shadeClose : true,
		//move : false,
		title:"网班详情",
		skin : 'layui-layer-rim', //加上边框
		btn : [ '关闭' ],
		content : ["wangban-detail.html?id="+id+"&winName="+window.name, 'no'],
		cancel : function(index) {
		}
	});
}
function wangbanPingjia(id) {
	layer.open({
		type : 2,
		area : [ '800px', '700px' ],
		fix : false, //不固定
		scrollbar : false,
		shadeClose : true,
		//move : false,
		title:"评价详情",
		skin : 'layui-layer-rim', //加上边框
		btn : [ '关闭' ],
		content : ["wangban-pingjia.html?id="+id+"&winName="+window.name, 'no'],
		cancel : function(index) {
		}
	});
}
function shenhe(auditType) {
	ids='';
	/* $("#findUser").find("input[name='checkall']").each(function(){
		if($(this).prop("checked")){
			ids+=$(this).val() +';' 
		}
		
	}); */
	ids=$("input[name='checkall']:checked").val();
	var auditt=$("input[name='checkall']:checked").attr("auditType");
	var statu=$("input[name='checkall']:checked").attr("statu");
	if(statu=='1' || statu=='2'){
		layer.msg("信息已审核");
		return false;
	}
	if(auditType!=auditt){
		layer.msg("请选择正确的审核类别");
		return false;
	}
	if(ids==''){
		layer.msg("请选择一条数据");
		return false;
	}
	$.ajax({
		type : "post",
		url : "./getSimilarity.do",
		dataType : "json",
		data:{
			"id":ids,
			"type":"2",
			"auditType":auditType
		},
		success : function(data) {
			if(data[0].result=='success'){
				toShenhe(ids,auditType);
			}else{
				layer.alert(data[0].msg,{title:'提示'});
			}
		},
		error : function(data) {
			alert("请求失败");
		}
	});
	
}
function toShenhe(ids,auditType){
	layer.open({
		type : 2,
		area : [ '700px', '350px' ],
		fix : false, //不固定
		scrollbar : false,
		shadeClose : true,
		//move : false,
		title:"审核",
		skin : 'layui-layer-rim', //加上边框
		btn : [ '保存 ', '关闭' ],
		content : ["shenhe.html?ids="+ids+"&type=2&auditType="+auditType+"&winName="+window.name, 'no'],
		yes : function(index,layer) {		
		 var iframeWin = parent.window[layer.find('iframe')[0]['name']];
		  			  iframeWin.save();
		},
		cancel : function(index) {
		}
	});
}
</script>